export function can(el, binding) {
  function warn(info, ...other) {
    console.warn('【v-can Auth】' + info, ...other);
    return false;
  }
  function dev_title(eel, auth, other_cond_arr, other_msg) {
    let title = `功能需要权限为: ${auth}`;
    if (other_cond_arr && other_cond_arr.length) {
      title += `, 其他权限为: ${other_cond_arr.map((c) => c ? 'true' : 'false')}`;
    }
    title += ` (指令表达式: ${binding.expression})`;

    return `${eel.title} ${other_msg ? `【${other_msg}】-` : ''}【${title}】`;
  }
  const value = binding.value || [];
  if (typeof value !== 'object' || !value.length) {
    return warn('【v-can】auth value 值错误(必须是一个数组)', value);
  }
  const auth_name = value[0] || ''; // 模块或功能权限
  const other_cond = value.slice(1); // 其他判断条件

  // 3. 权限判断
  const other_cond_is_true = other_cond.every((c) => c);
  if (!auth_instance.flat_check(auth_name) || !other_cond_is_true) {
    if (el && el.parentNode) {
      if (is_dev) {
        el.title = dev_title(el, auth_name, other_cond, '无权限访问'); // 测试环境
      }

      if (disabled) {
        el.className += ' is-disabled';
      } else {
        if (is_dev) {
          el.style.webkitFilter = 'grayscale(100%)';
          el.style.backgroundColor = 'grey';
          el.style.border = '1px solid red';
        } else {
          el.parentNode.removeChild(el);
        }
      }
    }
  } else {
    if (is_dev) {
      el.title = dev_title(el, auth_name, other_cond);
    }
  }
}